﻿Imports System.Data.OleDb

Partial Public Class StarHolders
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim starConn = New OleDbConnection(ConfigurationManager.ConnectionStrings _
                    ("ConnectionString").ToString())

        Dim sqlCount As String = "SELECT [MaterialName], [VisitedCount], [UserName], [ID] FROM [starHolder]"

        Dim findIDCmd As New OleDbCommand(sqlCount, starConn)
        starConn.Open()
       
        Dim dbread As OleDbDataReader = findIDCmd.ExecuteReader
        dbread.Read()


        ' Dim hitCount As Integer = dbread("VisitedCount")
        'Dim username As String = dbread("UserName")

        Do While dbread.Read()

            Console.WriteLine(dbread.GetInt32(1).ToString())
            Dim hitCount As Integer = dbread.GetInt32(1)
            Dim username As String = dbread.GetString(2)

            'If hitCount > 75 Then
            'Dim PotentialStar As String = "INSERT INTO PotentialUsers (UserName) VALUES(@UserName)"
            'Dim PotentialStarCmd As New OleDbCommand(PotentialStar, starConn)
            'PotentialStarCmd.Parameters.AddWithValue("@UserName", username)
            'PotentialStarCmd.ExecuteNonQuery()
            'End If

            'Console.WriteLine(vbTab & "{0}" & vbTab & "{1}", dbread.GetInt32(0), dbread.GetString(1))
        Loop
         
       
        

    End Sub

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        If e.CommandName = "rank" Then

            Dim index As Integer = Convert.ToInt32(e.CommandArgument)

            Response.Redirect("details.aspx?materialID=" & GridView1.DataKeys(index).Value.ToString())
        End If
    End Sub
End Class